# -*- coding: utf-8 -*-

from pageobjects.basepage import BasePage
from common.base import *

class LoginPage(BasePage):
    """
    封装当前页面使用的公共方法,继承basepage页面
    """
    # 定位元素
    username_loc = '//*[@id="app"]/div/section/form/div[1]/div/div/input'  # 用户名
    password_loc = '//*[@id="app"]/div/section/form/div[2]/div/div/input'  # 密码
    login_loc = '//*[@id="app"]/div/section/form/div[3]/div/button'  # 登录按钮
    tankuang = '/html/body/div[2]'


    # 重写父类的open()方法
    def open(self):
        self._open(self.url)

    def username_content(self, content):
        # 调用父类的find_emelemt，然后将本类的参数传入
        username_content = self.find_emelemt(self.username_loc)[1]
        username_content.clear()
        username_content.send_keys(content)

    def password_content(self, content):
        password_content = self.find_emelemt(self.password_loc)[1]
        password_content.clear()
        password_content.send_keys(content)

    def btn_click(self):
        btn1 = self.find_emelemt(self.login_loc)[1]
        btn1.click()

    def message(self):
        flag = self.find_emelemt(self.tankuang)[0]
        return flag
